package org.dragonnova.meetingapp.app.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.webkit.WebView;

import org.dragonnova.meetingapp.R;

public class WebActivity extends AppCompatActivity {

    private WebView web_wv;

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        if (getSupportActionBar() != null) getSupportActionBar().setDisplayShowTitleEnabled(false);

        web_wv = (WebView) findViewById(R.id.web_wv);
        if (web_wv != null) {
            web_wv.getSettings().setJavaScriptEnabled(true);
            Intent intent = getIntent();
            if (intent != null) {
                String ip = intent.getStringExtra("ip");
                if (!TextUtils.isEmpty(ip)) {
                    web_wv.loadUrl(ip);
                }
            }
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        web_wv.removeAllViews();
        web_wv.destroy();
        web_wv =null;
    }
}
